//package com.atguigu.spzx.config;
//
//import org.ehcache.CacheManager;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.cache.RedisCacheConfiguration;
//import org.springframework.data.redis.cache.RedisCacheManager;
//import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
//import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
//import org.springframework.data.redis.serializer.RedisSerializationContext;
//import org.springframework.data.redis.serializer.StringRedisSerializer;
//
//import java.time.Duration;
//
//// com.atguigu.spzx.cache.config;
//@Configuration
//public class RedisConfig {
//
//    @Bean
//    public CacheManager cacheManager(LettuceConnectionFactory connectionFactory) {
//
//        //定义序列化器
//        GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
//        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
//
//
//        RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
//                //过期时间600秒
//                .entryTtl(Duration.ofSeconds(600))
//                // 配置序列化
//                .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(stringRedisSerializer))
//                .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(genericJackson2JsonRedisSerializer));
//
//        RedisCacheManager cacheManager = RedisCacheManager.builder(connectionFactory)
//                .cacheDefaults(config)
//                .build();
//
//        return cacheManager;
//    }
//
//}